package com.itheima.controller;

import com.itheima.dao.DeptMapper;
import com.itheima.dao.EmpMapper;
import com.itheima.dao.StudentMapper;
import com.itheima.pojo.Teacher;
import jakarta.annotation.Resource;
import lombok.AllArgsConstructor;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
//lombok提供 , 搭配@Autowired构造全参构造器(必须全为bean对象才能使用此方法)
//@AllArgsConstructor
@RequestMapping("/Auto")
public class TestAutowired {
    EmpMapper empMapper;
    DeptMapper deptMapper;
    StudentMapper studentMapper;

    @Resource(name="zhangsan")
    Teacher teacher;

    @Resource
    Teacher lisi;

    @GetMapping
    public void test(){
        System.out.println("teacher1 = " + teacher);
        System.out.println("teacher2 = " + lisi);
    }
}
/**
 * SpringBean 注入时要注意的问题 :
 * 1. 非bean不能调用bean
 * 2. 不能形成循环依赖 -> 如何解决? (高频面试题)
 */
